package gw.com.android.utils;

import android.content.Context;

import com.gwtsz.gts2.hx.BuildConfig;

/**
 * 打包环境
 *
 * @author jett
 * @since 2017-09-25.
 */
public class ENV {

    private static final boolean isUat;
    private static final boolean isPrd;
    private static final boolean isRelease;
    private static int appIcon = 0;

    static {
        isUat = "uat".equals(BuildConfig.ENV);
        isPrd = "prd".equals(BuildConfig.ENV);
        isRelease = "release".equals(BuildConfig.ENV);
        if (!isUat && !isPrd && !isRelease) {
            throw new IllegalArgumentException("ENV is illegal,please verify your environment in build.gradle.. ENV = " + BuildConfig.ENV);
        }
    }

    public static boolean isUat() {
        return isUat;
    }

    public static boolean isPrd() {
        return isPrd;
    }

    public static boolean isRelease() {
        return isRelease;
    }

    public static boolean isVest() {
        return false;
    }

    public static String getAppName() {
        return BuildConfig.APP_NAME;
    }

    public static int getAppIcon(Context context) {
        if (appIcon == 0) {
            String resName = BuildConfig.APP_ICON;
            appIcon = context.getResources().getIdentifier(resName, "mipmap", BuildConfig.APPLICATION_ID);
        }
        return appIcon;
    }

}
